#include <bits/stdc++.h>
using namespace std;

const int N = 100005;
int n, k, cnt, p[N][2], dp[N][101];
struct Pair {
    int x, y;
} P[N];

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> P[i].x >> P[i].y;
    sort(P + 1, P + n + 1, [](Pair a, Pair b) { return a.x < b.x; });

    for (int i = 1; i <= n; i++) {
        if (P[i].x >= p[cnt][0] && P[i].y <= p[cnt][1])
            continue;
        if (P[i].x < p[cnt][0] && P[i].y > p[cnt][1])
            cnt--;
        p[++cnt][0] = P[i].x, p[cnt][1] = P[i].y;
    }

    k -= n - cnt; 
    if (k < 0)
        k = 0; 

    for (int i = 1; i <= cnt; i++) {
        for (int j = 0; j <= min(i - 1, k); j++) {
            for (int t = max(0, i - j - 1); t < i; t++) {
                int add = max(0, (t == 0 ? p[i][1] - p[i][0] : p[i][1] - max(p[i][0], p[t][1])));
                dp[i][j] = max(dp[i][j], dp[t][j - (i - t - 1)] + add);            
            }
        }
    }

    int ans = 0;
    for (int i = 1 + cnt - k; i <= cnt; i++) 
        ans = max(ans, dp[i][k - (cnt - i)]);
    cout << ans << endl;
    return 0;
}